/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_ARM64_VPMEM_H
#define _ASM_ARM64_VPMEM_H

#include <linux/types.h>

#define E820_X_MAX 3200

enum e820_type {
	E820_TYPE_RAM		= 1,
	E820_TYPE_RESERVED	= 2,
	E820_TYPE_ACPI		= 3,
	E820_TYPE_NVS		= 4,
	E820_TYPE_UNUSABLE	= 5,
	E820_TYPE_OSP_NVRAM	= 6,
	E820_TYPE_OSP_MEM	= 7,
	E820_TYPE_PCIE_OPP	= 8,
	E820_TYPE_BIOS_MEM	= 9,
	E820_TYPE_PBS		= 10,
	E820_TYPE_BIOS_FLASH	= 11,
	E820_TYPE_PCIE_MEM	= 12,
	E820_TYPE_MEM_VOS	= 13,
	E820_TYPE_MEM_USER	= 14,
	E820_TYPE_VPMEM		= 64,
	E820_TYPE_PRAM		= 127,
	E820_TYPE_RESERVED_KERN	= 128,
	E820_TYPE_TMP		= 0xFF, /* kernel use for temporary */
	E820_TYPE_MEM_FAULT	= 0xF0000001, /* fault memory defined by bios */
};

/* Keep these macros for compatibility */
#define E820_RAM		E820_TYPE_RAM
#define E820_RESERVED		E820_TYPE_RESERVED
#define E820_ACPI		E820_TYPE_ACPI
#define E820_NVS		E820_TYPE_NVS
#define E820_UNUSABLE		E820_TYPE_UNUSABLE
#define E820_OSP_NVRAM		E820_TYPE_OSP_NVRAM
#define E820_OSP_MEM		E820_TYPE_OSP_MEM
#define E820_PCIE_OPP		E820_TYPE_PCIE_OPP
#define E820_BIOS_MEM		E820_TYPE_BIOS_MEM
#define E820_PBS		E820_TYPE_PBS
#define E820_BIOS_FLASH		E820_TYPE_BIOS_FLASH
#define E820_PCIE_MEM		E820_TYPE_PCIE_MEM
#define E820_MEM_VOS		E820_TYPE_MEM_VOS
#define E820_MEM_USER		E820_TYPE_MEM_USER
#define E820_VPMEM		E820_TYPE_VPMEM
#define E820_PRAM		E820_TYPE_PRAM
#define E820_RESERVED_KERN	E820_TYPE_RESERVED_KERN
#define E820_TMP		E820_TYPE_TMP
#define E820_MEM_FAULT		E820_TYPE_MEM_FAULT

struct e820entry {
	__u64 addr;	/* start of memory segment */
	__u64 size;	/* size of memory segment */
	__u32 type;	/* type of memory segment */
} __packed;

struct e820map {
	__u32 nr_entries;
	struct e820entry entries[E820_X_MAX];
};

extern struct e820map e820;

extern void e820__range_add(u64 start, u64 size, enum e820_type type);
extern u64  e820__range_update(u64 start, u64 size,
		enum e820_type old_type, enum e820_type new_type);
extern void e820__print_table(char *who);

/* arm64 specific api */
extern void request_vpmem_res_resource(void);
extern void reserve_vpmem(void);
extern void vpmem_early_init_dt(void);

#endif /* _ASM_ARM64_VPMEM_H */
